namespace :bilibiliranking do
  desc "bilibili ranking #7"
  task :r7 => :environment do
    require 'lib/tasks/vegas_video_maker.rb'
    require 'lib/tasks/bili_ranking_maker.rb'
    include VegasVideoMaker
    date_now = Time.now
    puts "Task start~"
    #======================================
    pa = "#{BILI_PRO_PATH}#{ENV['pa']}\\"
    options = YAML.load(open(File.join(%[#{pa}options.yml])))
    default_bgm = "Sakuranbo_Kiss_Instrumental.mp3"
    doc, vvm = BRM.create({:path => pa})
    puts "-=Building xml=-"
    #======================================
    vvm.op.pics("op", 1..2, :length => 6).pics("rule", 1..4, :length => 5
    ).title(1).music("bilibili.mp3", vvm.vvmtime - 1, :start_time => VVMTime.nl(15)
    ).list1(21..35, options[:rank])
    vvm.title(2, true).pickup(options[:pickup])
    vvm.title(3, true).list1(11..20, options[:rank])
    vvm.play_bgm('1.mp3') do
      vvm.pics "rest", 1..2, :length => 7
    end
    vvm.tag(options[:tag], 1..4)
    vvm.title(4, true).list1(4..10, options[:rank])
    vvm.play_bgm('1.mp3') do
      vvm.pics('weekly', [1]).pics "rest", 3..4, :length => 7
    end
    vvm.history(options[:history])
    vvm.list3(options[:rank])
    vvm.play_bgm(default_bgm) do
      vvm.pics "rest", [6], :length => VVMTime.new(0, 0, 6, 15)
      vvm.title(5).list2({}, 12..41).logo.ed
    end
    #======================================
    doc.write File.open(pa + "xml.xml", 'w')
    puts vvm.vvmtime
    puts "#{Time.now - date_now} second complete"
  end
end


